import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isRightClickMenu: false,
    selectMenuTtem: {},
    rightMenu: [
      {
        name: '添加子菜单',
        method: '',
        param: "",
        children: [{
          name: "子节点1",
          method: 'handleItemData',
          param: "son1",
        },
        {
          name: '子节点2',
          method: 'handleItemData',
          param: "son2",
        },]
      },
      {
        name: '添加兄弟菜单',
        method: '',
        children: [{
          name: "兄弟节点1",
          method: 'handleItemData',
          param: "bro1",
        },
        {
          name: '兄弟节点2',
          method: 'handleItemData',
          param: "bro2",
        },]
      },
      {
        name: '删除',
        method: 'handleItemDel',

      }
    ],
    rightMenuPosition: {
      x: 0, y: 0
    },
    pageFormConfig: {
      title: "",
      item: []
    }
  },
  mutations: {
    // 右键菜单内容
    setRightMenu(state, value) {
      state.rightMenu = value
    },
    // 右键菜单位置
    setRightMenuPosition(state, value) {
      state.rightMenuPosition = value
    },
    // 是否显示右键菜单
    setIsRightClickMenu(state, value) {
      state.isRightClickMenu = value
    },
    // 设置选中的右键菜单
    setSelectMenuTtem(state, value) {
      state.selectMenuTtem = value
    },
    // 设置 pageFormConfig
    setPageFormConfig(state, obj) {
      state.pageFormConfig = {
        title: obj.title || "",
        item: obj.item || []
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
